VintaSoft Imaging .NET SDK 14.0: Documentation for .NET developer
Vintasoft.Imaging.Codecs.ImageFiles.Raw Namespace / NefPage Class / GetPreviewImage Methods / GetPreviewImage(EventHandler<ProgressEventArgs>) Method
Syntax Example Requirements SeeAlso
In This Topic
    GetPreviewImage(EventHandler<ProgressEventArgs>) Method (NefPage)
    In This Topic
    Returns a preview image associated with this image page.
    Syntax
    'Declaration
    
    Public Overloads Overrides Function GetPreviewImage( _
    ByVal progressDelegate
    Progress delegate. Can be set to null (Nothing in Visual Basic).
    As System.EventHandler(Of ProgressEventArgs) _
    ) As Vintasoft.Imaging.VintasoftImage

    Parameters

    progressDelegate
    Progress delegate. Can be set to null (Nothing in Visual Basic).

    Return Value

    The preview image associated with this ImagePage object if preview image was loaded successfully; otherwise, null.
    Example

    Here is an example that shows how to open Nikon NEF-file, get preview image from NEF-file and save image to a PNG-file:

    
    ''' <summary>
    ''' Opens Nikon NEF-file, gets preview image from NEF-file and saves image to a PNG-file.
    ''' </summary>
    ''' <param name="nefFilename">The name of NEF-file.</param>
    Public Sub GetAndSaveNefPreviewImage(nefFilename As String)
        ' open NEF-file stream
        Using fs As New System.IO.FileStream(nefFilename, System.IO.FileMode.Open, System.IO.FileAccess.Read)
            ' open CRNEFW-file
            Dim rawImageFile As New Vintasoft.Imaging.Codecs.ImageFiles.Raw.RawImageFile(fs)
            ' get NEF-page
            Dim nefPage As Vintasoft.Imaging.Codecs.ImageFiles.Raw.NefPage = TryCast(rawImageFile.Page, Vintasoft.Imaging.Codecs.ImageFiles.Raw.NefPage)
            ' if NEF-page is found in RAW-file
            If nefPage IsNot Nothing Then
                ' get preview image image from NEF-file
                Using previewImage As Vintasoft.Imaging.VintasoftImage = nefPage.GetThumbnailImage()
                    ' save image to a PNG file
                    previewImage.Save(nefFilename & ".png")
                End Using
            End If
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Opens Nikon NEF-file, gets preview image from NEF-file and saves image to a PNG-file.
    /// </summary>
    /// <param name="nefFilename">The name of NEF-file.</param>
    public void GetAndSaveNefPreviewImage(string nefFilename)
    {
        // open NEF-file stream
        using (System.IO.FileStream fs = new System.IO.FileStream(nefFilename, System.IO.FileMode.Open, System.IO.FileAccess.Read))
        {
            // open CRNEFW-file
            Vintasoft.Imaging.Codecs.ImageFiles.Raw.RawImageFile rawImageFile =
                new Vintasoft.Imaging.Codecs.ImageFiles.Raw.RawImageFile(fs);
            // get NEF-page
            Vintasoft.Imaging.Codecs.ImageFiles.Raw.NefPage nefPage =
                rawImageFile.Page as Vintasoft.Imaging.Codecs.ImageFiles.Raw.NefPage;
            // if NEF-page is found in RAW-file
            if (nefPage != null)
            {
                // get preview image image from NEF-file
                using (Vintasoft.Imaging.VintasoftImage previewImage = nefPage.GetThumbnailImage())
                {
                    // save image to a PNG file
                    previewImage.Save(nefFilename + ".png");
                }
            }
        }
    }
    
    

    Requirements

    Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also